
<?php
class pagination_mdl extends CI_Model
{
    public function __construct() {
        parent::__construct();
    }
 
    public function record_count2() {
        return $this->db->count_all("fournisseurs");
    }
 
    public function fetch_countries($limit, $start) {
        $this->db->limit($limit, $start);
        $query = $this->db->get("fournisseurs");
 
        if ($query->num_rows() > 0) {
            foreach ($query->result() as $row) {
                $data[] = $row;
            }
            return $data;
        }
        else return false;
   }
   
   
    public function record_count() {
	  	
      $q = $this->db->query("SELECT 
	  fournisseurs.id_fournisseur,
fournisseurs.nom,
fournisseurs.adresse,
fournisseurs.tel,
fournisseurs.id_wilaya_fk,
fournisseurs.id_convetion_fk,
fournisseurs.comments,
conventions.id_convetion
FROM
fournisseurs
INNER JOIN conventions ON fournisseurs.id_convetion_fk = conventions.id_convetion
INNER JOIN articles ON conventions.id_article_fk = articles.id_article
WHERE
articles.id_article = 2
");

$cont=$q->num_rows();
return $cont;

    }
   
   public function get_all2($limit, $start,$nbr_article)
	{

	//$art = intval($xxx);
	$query = $this->db->query("SELECT 
fournisseurs.id_fournisseur,
fournisseurs.nom,
fournisseurs.adresse,
fournisseurs.tel,
fournisseurs.id_wilaya_fk,
fournisseurs.id_convetion_fk,
fournisseurs.comments,
conventions.id_convetion
FROM
fournisseurs
INNER JOIN conventions ON fournisseurs.id_convetion_fk = conventions.id_convetion
INNER JOIN articles ON conventions.id_article_fk = articles.id_article
WHERE
articles.id_article = $nbr_article
LIMIT  $start ,$limit
 ");

  if ($query->num_rows() > 0) {
            foreach ($query->result() as $row) {
                $data[] = $row;
            }
            return $data;
        }
        else return false;

	
	}
}
?>